package org.xxpay.pay.channel.sqpay;

import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

/**
 * @author: dingzhiwei
 * @date: 18/12/14
 * @description: 双乾配置
 */
@Component
public class SqpayConfig {

    public final static String CHANNEL_NAME_SQPAY = "sqpay"; 	    // 渠道名称:双乾代付
    public final static String CHANNEL_NAME_SQPAY_B2C= "sqpay_b2c"; 	    // 渠道名称:双乾代付
    public final static String CHANNEL_NAME_SQPAY_B2B= "sqpay_b2b"; 	    // 渠道名称:双乾代付
    public static final String RETURN_PARAM_RETCODE = "retCode";	// 通讯返回码
    public static final String RETURN_VALUE_SUCCESS = "success";    // 成功
    public static final String RETURN_VALUE_FAIL = "fail";          // 失败

    private String merNo;               // 商户号
    private String reqUrl;              // 提交地址
    private String privateKey;          // 商户私钥
    private String sqPublicKey;         // 双乾公钥
    private String sqBalanceKey;        // 双乾余额查询密码
    private String MD5key;

    public SqpayConfig() {
    }

    public SqpayConfig(String payParam) {
        Assert.notNull(payParam, "init sqpay config error");
        JSONObject object = JSONObject.parseObject(payParam);
        this.merNo = object.getString("merNo");
        this.reqUrl = object.getString("reqUrl") == null ? "" : object.getString("reqUrl");
        this.privateKey = object.getString("privateKey") == null ? "" : object.getString("privateKey");
        this.sqPublicKey = object.getString("sqPublicKey") == null ? "" : object.getString("sqPublicKey");
        this.sqBalanceKey = object.getString("sqBalanceKey") == null ? "" : object.getString("sqBalanceKey");
        this.MD5key = object.getString("MD5key") == null ? "" : object.getString("MD5key");
    }

    public String getMerNo() {
        return merNo;
    }

    public void setMerNo(String merNo) {
        this.merNo = merNo;
    }

    public String getReqUrl() {
        return reqUrl;
    }

    public void setReqUrl(String reqUrl) {
        this.reqUrl = reqUrl;
    }

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public String getSqPublicKey() {
        return sqPublicKey;
    }

    public void setSqPublicKey(String sqPublicKey) {
        this.sqPublicKey = sqPublicKey;
    }

    public String getSqBalanceKey() { return sqBalanceKey; }

    public void setSqBalanceKey(String sqBalanceKey) { this.sqBalanceKey = sqBalanceKey; }

    public String getMD5key() { return MD5key; }

    public void setMD5key(String MD5key) { this.MD5key = MD5key; }
}
